#!  python
# -*- coding: UTF-8 -*-
'''
@Author ：Star
@Date ：2022/9/30  
'''
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

op = webdriver.ChromeOptions()
op.add_experimental_option("excludeSwitches", ["enable-automation"])
op.add_experimental_option("useAutomationExtension", False)
driver =webdriver.Chrome(options=op)
driver.get("http://118.121.200.162:8085/index")


driver.find_element(By.XPATH,"/html/body/div[1]/nav/div[2]/div/ul/li[1]/a").click()
sleep(2)

#userID
user = "star"
driver.find_element(By.CSS_SELECTOR,"#userID").send_keys(user)
driver.find_element(By.CSS_SELECTOR,"#password").send_keys("123456")
sleep(2)
#submit
driver.find_element(By.CSS_SELECTOR,"#submit").click()
sleep(2)
driver.switch_to.alert.dismiss() #关闭弹窗
sleep(2)
logUser = driver.find_element(By.CSS_SELECTOR,"#navbar > div > ul > li:nth-child(1) > a > p").text
print(logUser)
assert user in logUser
print("success")
driver.quit()